package cn.tedu.lucky.draw.server.job.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;

@Slf4j
public class ActivityJobListener implements JobExecutionListener {

    @Override
    public void beforeJob(JobExecution jobExecution) {
        long begin = System.currentTimeMillis();
        jobExecution.getExecutionContext().putLong("begin", begin);
        log.debug("开始时间：{}", begin);
    }

    @Override
    public void afterJob(JobExecution jobExecution) {
        long end = System.currentTimeMillis();
        long begin = jobExecution.getExecutionContext().getLong("begin");
        log.debug("耗时：{}ms", end - begin);
    }
}
